﻿using System;
using System.Data;
namespace SmartLibraries.DataAccessLayer
{
	public abstract class SmartBaseQuery : ISmartQuery
	{

		public  string Connectionstring
		{
			get;
			set;
		}
		public  SmartDbParameters Parameters
		{
			get;
			set;
		}
		public string Query
		{
			get;
			set;
		}

		protected SmartBaseQuery(string strConnectionstring)
		{
			this.Connectionstring = strConnectionstring;
		}

		protected abstract ISmartBaseDal GetHelper();

		#region Public Methods
		public int ExecuteNonQuery()
		{
			using(ISmartBaseDal objDal= this.GetHelper())
			{
				return objDal.ExecuteNonQuery();
			}
		}
		public DataTable GetDataTable()
		{
			using(ISmartBaseDal objDal = this.GetHelper())
			{
				return objDal.GetDataTable();
			}
		}
		public DataSet GetDataSet()
		{
			using(ISmartBaseDal objDal = this.GetHelper())
			{
				return objDal.GetDataSet();
			}
		}
		public SingleRow GetSingleRow()
		{

			using(ISmartBaseDal objDal = this.GetHelper())
			{
				return objDal.GetSingleRow();
			}
		}
		#endregion

		public void Dispose()
		{
			this.Connectionstring = null;
			this.Parameters = null;
			this.Query = null;
		}
		
	}
}
